home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGMISC / FPCDOCS.LZH / ASSEMBLY.DOC next >
Text File  |  1988-06-01  |  8KB  |  181 lines

  1. XI.   PASM, THE F-PC ASSEMBLER
  2.  
  3.  
  4.  
  5.  
  6. PASM.SEQ is an assembler which is based on an assembler published 
  7. in DDJ, February 1982 by Ray Duncan. That assembler was 
  8. subsequently modified by Robert L. Smith to repair bugs, and 
  9. support the prefix assembler notation.  Bob discovered a very 
  10. simple method to let a postfix assembler to assemble prefix code, 
  11. by deferring assembly until the next assembler command, when all 
  12. the arguments for the previous assembler command are piled on the 
  13. top of the data stack.  Tom Zimmer have made additional 
  14. modifications to allow switching syntaxes, and to increase 
  15. compatibility in postfix mode with the F83 Assembler. 
  16.  
  17. It is not appropriate to
  18. discuss the joy and frustrations in working at such a low level in 
  19. this manual.  However, F-PC provides the best environment for you
  20. to do experiments using assembly language, because you can first 
  21. verify the algorithm and methodology in high level Forth code and 
  22. gradually reducing the code to the assembly level.  You will find 
  23. numerous examples in which the high level code in F83 is recoded
  24. in assembly, besides most of the F-PC kernel words which were in
  25. assembly already. 
  26.  
  27. The best way to learn 80x8x assembly language is using PASM, armed 
  28. with all the examples of code words in F-PC.  Factor your code
  29. carefully so that each word can be conveniently recoded in 
  30. assembly.  Take the kernel words as templates to start with, and 
  31. modify them so that they will do exactly what you want them to do.
  32.  
  33.  
  34.  
  35. 1.  PREFIX OR POSTFIX ? 
  36.  
  37.  
  38.  
  39. PASM supports dual syntaxes. The words PREFIX and POSTFIX switch 
  40. between the two supported modes. The postfix mode is very similar 
  41. to F83's CPU8086 Assembler. Prefix mode which is the default mode, 
  42. allows a syntax which is much closed to MASM. 
  43.  
  44. The assembler supports prefix syntax, in an attempt to provide a 
  45. syntax which is more readable to programmers of other languages. 
  46. It supports postfix syntax to prevent alienating the established 
  47. base of F83 users. 
  48.  
  49. The prefix notation is close to the original Intel assembly 
  50. syntax, and certainly will be more familiar to programmers of 
  51. other languages. Please consider writting any new assembly code 
  52. you need in the prefix mode for distribution and assimilation. 
  53.  
  54. The assembly of a machine instruction is generally deferred to the 
  55. following three events: when the next assembly mnemonic is 
  56. encountered, at the end of a line, or when the command END-CODE or 
  57. A; is executed.  Therefore, a good style in writing code words in 
  58. F-PC is to put one assembly instruction in one line, followed by
  59. the parameter specification or the arguments.  Multiple assembly 
  60. instructions are allowed in the same line, except the assembly 
  61. directives which build control structures in a code word, such as 
  62. IF, ELSE, THEN, BEGIN, WHILE, AGAIN, etc.  These directives must 
  63. be the first or the only instruction in a line because they act 
  64. immediately, not waiting for the next assembly instruction. 
  65.  
  66.  
  67.  
  68. 2.   PASM GLOSSARY
  69.  
  70.  
  71.  
  72. Here we will only give a small list of of PASM words in this 
  73. glossary.  All assembly mnemonics are identical to those defined 
  74. in F83 8086 Assembler.  All the structure directives and test 
  75. conditions are also identical to those in F83.  Only the most 
  76. important FORTH words controlling the assembler are listed here. 
  77.  
  78. PREFIX    ( -- )
  79.  
  80. Assert prefix mode for the following code definitions.
  81.  
  82. POSTFIX   ( -- )
  83.  
  84. Assert postfix mode for the following code definitions.
  85.  
  86. CODE      ( | name --- ) 
  87.  
  88. Define "name" as a new code definition. Assembly language follows, 
  89. terminated by END-CODE. 
  90.  
  91. A:        Alias of CODE. 
  92.  
  93. END-CODE  ( --- ) 
  94.  
  95. Terminates CODE definitions, checks error conditions, and makes 
  96. the code definition available for searching and execution. 
  97.  
  98. A;        Alias of END-CODE. 
  99.  
  100.  
  101.  
  102. 3.   SYNTAX COMPARISON
  103.  
  104.  
  105.  
  106. The differences among the F-PC prefix mode, the F83 postfix mode,
  107. and the Intel MASM notation are best illustrated by the following 
  108. table.  Although the table is not exhaustive, it covers most of 
  109. the cases useful in doing PASM programming.  You are welcome to 
  110. suggest additional cases to be included in this table. 
  111.  
  112.  
  113.  
  114.         PREFIX                  POSTFIX                 MASM
  115.  
  116.         AAA                     AAA                     AAA
  117.         ADC AX, SI              SI AX ADC               ADC AX,SI
  118.         ADC DX, 0 [SI]          0 [SI] DX ADC           ADC DX,0[SI]
  119.         ADC 2 [BX+SI], DI       DI 2 [BX+SI] ADC        ADC 2[BX][SI],DI
  120.         ADC MEM BX              BX MEM #) ADC           ADC MEM,BX
  121.         ADC AL, # 5             5 # AL ADC              ADC AL,5
  122.         AND AX, BX              BX AX AND               AND AX,BX
  123.         AND CX, MEM             CX MEM #) AND           AND CX,MEM
  124.         AND DL, # 3             3 # DL AND              AND DL,3
  125.         CALL NAME               NAME #) CALL            CALL NAME
  126.         CALL FAR [] NAME        FAR [] NAME #) CALL     ?????
  127.         CMP DX, BX              BX DX CMP               CMP DX,BX
  128.         CMP 2 [BP], SI          SI 2 [BP] CMP           CMP [BP+2],SI
  129.         DEC BP                  BP DEC                  DEC BP
  130.         DEC MEM                 MEM DEC                 DEC MEM
  131.         DEC 3 [SI]              3 [SI] DEC              DEC 3[SI]
  132.         DIV CL                  CL DIV                  DIV CL
  133.         DIV MEM                 MEM DIV                 DIV MEM
  134.         IN PORT# WORD           WORD PORT# IN           IN AX,PORT#
  135.         IN PORT#                PORT# IN                IN AL,PORT#
  136.         IN AX, DX               DX AX IN                IN AX,DX
  137.         INC MEM                 BYTE MEM INC            INC MEM BYTE
  138.         INC MEM WORD            MEM #) INC              INC MEM WORD
  139.         INT 16                  16 INT                  INT 16
  140.         JA NAME                 NAME JA                 JA NAME
  141.         JNBE NAME               NAME #) JNBE            JNBE NAME
  142.         JMP NAME                NAME #) JMP             JMP
  143.         LODSW                   AX LODS                 LODS WORD
  144.         LODSB                   AL LODS                 LODS BYTE
  145.         LOOP NAME               NAME #) LOOP            LOOP NAME
  146.         MOV AX, BX              BX AX MOV               MOV AX,BX
  147.         MOV AH, AL              AL AH MOV               MOV AH,AL
  148.         MOV BP, 0 [BX]          0 [BX] BP MOV           MOV BP,0[BX]
  149.         MOV ES: BP, SI          ES: BP SI MOV           MOV ES:BP,SI
  150.         MOVSW                   AX MOVS                 MOVS WORD
  151.         POP DX                  DX POP                  POP DX
  152.         POPF                    POPF                    POPF
  153.         PUSH SI                 SI PUSH                 PUSH SI
  154.         REP                     REP                     REP
  155.         RET                     RET                     RET
  156.         ROL AX, # 1             AX ROL                  ROL AX,1
  157.         ROL AX, CL              AX CL ROL               ROL AX,CL
  158.         SHL AX, # 1             AX SHL                  SHL AX,1
  159.         XCHG AX, BP             BP AX XCHG              XCHG AX,BP
  160.         XOR CX, DX              DX, CX XOR              XOR CX,DX
  161.  
  162.  
  163.  
  164. 4.   MACROS IN PASM 
  165.  
  166.  
  167.  
  168. Another area of interest is macros, here is the definition of the 
  169. NEXT macro: 
  170.  
  171.           : NEXT  >PRE    JMP >NEXT A;    PRE> ; 
  172.  
  173. The macro itself is simply the sequence JMP >NEXT. The surrounding 
  174. words are used for support. Since PASM supports both postfix as 
  175. well as prefix notation, It is not know on entry to a macro what 
  176. mode is selected. The words >PRE and PRE> select prefix, and 
  177. restore the previous mode so macros will always be in prefix 
  178. notation. The A; after >NEXT, forces the assembly of the JMP 
  179. instruction before the mode switch. 
  180.  
  181.